<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<style>
    body {
        height: auto;
        font-family: "Microsoft YaHei";
    }
    button {
        font-family: "SimSun", "Helvetica Neue", Helvetica, Arial;
    }
</style>
<body class="hold-transition box box-main">
<input id="treeId" name="treeId" type="hidden"/>
<input id="roleId" name="roleId" type="hidden"/>
<input id="treeName" name="treeName" type="hidden"/>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            用户账号：<input type="text" name="userLoginName"/>
                        </li>
                        <li>
                            用户类型：<select name="params[roleId]" th:with="type=${@dict.getType('user_role')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        <li>
                            实名认证：<select name="certState" th:with="type=${@dict.getType('pay_user_cert_state')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li class="select-time">
                            <label>注册时间： </label>
                            <input type="text" class="date-time-input" id="startCreateTime" placeholder="开始" name="params[beginCreateTime]"/>
                            <span>-</span>
                            <input type="text" class="date-time-input" id="endCreateTime" placeholder="结束" name="params[endCreateTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "manager/user";
    var roleid = "select_all";
    var userRoleDir = [[${@dict.getType('user_role')}]];
    var accountStateDir = [[${@dict.getType('pay_accout_state')}]];
    var certStateDir = [[${@dict.getType('pay_user_cert_state')}]];
    $(function () {
        var options = {
            url: prefix + "/list/" + roleid,
            modalName: "承兑商",
            search: false,
            showExport: false,
            columns: [
                {
                    field: 'id',
                    title: '用户编号',
                    visible: true
                },
                {
                    field: 'userLoginName',
                    title: '用户账号',
                    sortable: false
                },
                {
                    field: 'roleId',
                    title: '用户类型',
                    sortable: false,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(userRoleDir, value);
                    }
                },
                {
                    field: 'accoutState',
                    title: '用户状态',
                    sortable: false,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(accountStateDir, value);
                    }
                },
                {
                    field: 'realname',
                    title: '姓名',
                    sortable: false
                },
                {
                    field: 'certState',
                    title: '实名认证状态',
                    sortable: false,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(certStateDir, value);
                    }
                },
            ]
        };
        $.table.init(options);

        var oldSelected = null;
        $(function () {
            $('#bootstrap-table').on('click-row.bs.table', function (e, row, element) {
                if (oldSelected) {
                    oldSelected.css({"background": "white"});
                }
                oldSelected = $(element);
                $(element).css({"background": "Khaki"});
                console.log(row);
                var treeId = row.id;
                var roleId = row.roleId;
                var treeName = row.realname;
                $("#treeId").val(treeId);
                $("#roleId").val(roleId);
                $("#treeName").val(treeName);
            });
        })
    });
</script>
</body>
</html>
